<template>
	<view class="detail">
		<view class="title_box">
			<text>{{options.type==1?'供':'需'}}</text>
			<text>{{options.title}}</text>
		</view>
		<view class="text_box">
			<text>发布人：{{options.contacts}}</text>
			<text>发布时间：{{options.startTime}}</text>
			<view :style="`background:${options.status==1?'#628FCB':'#A5A5B0'}`">
				<text>{{options.status==1?'发布中':'已关闭'}}</text>
			</view>
		</view>
		<view class="content_box">
			<text v-html="options.introduce">
			</text>
		</view>
		<view class="image_box" v-if="options.goodsPic">
			<text>相关图片</text>
			<view>
				<image @click="prewImage(item)" :src="fullImage(item)" mode=""
					v-for="(item,index) in options.goodsPic.split(',')" :key="index">
				</image>
			</view>
		</view>
		<button type="submit" class="submit" @click="handleClick" v-if="options.status==1">
			<image src="../../static/phone_icon.png"></image>立即联系
		</button>
	</view>
</template>

<script>
	import {fullImage} from '@/utils/api.js'
	export default {
		data() {
			return {
				options: {}
			}
		},
		onLoad(option) {
			this.options = JSON.parse(decodeURIComponent(option.item))
		},
		methods: {
			fullImage,
			handleClick() {
				console.log(this.options.phone);
				uni.makePhoneCall({
					phoneNumber: this.options.phone,
				})
			},
			prewImage(item) {
				let url = fullImage(item);
				uni.previewImage({
					count: 0,
					urls: [url]
				});
			},
		},
	}
</script>

<style lang="less" scoped>
	.detail {
		width: 100%;
		padding: 28upx;

		>.title_box {
			margin-bottom: 28upx;

			>text {
				&:nth-of-type(1) {
					font-size: 26upx;
					color: #ffffff;
					padding: 0 10upx;
					background: #628fcb;
					border-radius: 16upx 0px 16upx 0px;
					margin-right: 12upx;
				}

				&:nth-of-type(2) {
					font-size: 34upx;
					color: #333333;
					font-weight: 600;
				}
			}
		}

		.text_box {
			width: 100%;
			font-size: 24upx;
			color: #666;
			margin-bottom: 28upx;
			line-height: 50upx;
			position: relative;

			>text {
				display: block;
			}

			>view {
				width: 85upx;
				height: 85upx;
				border-radius: 18upx;
				display: flex;
				justify-content: center;
				align-items: center;
				position: absolute;
				top: 50%;
				right: 0;
				transform: translateY(-50%);

				>text {
					font-size: 20upx;
					color: #ffffff;
				}
			}
		}

		.content_box {
			width: 100%;
			text-align: justify;
			padding: 28upx;
			margin-bottom: 28upx;
			background: #fff;
			border-radius: 18upx;

			>text {
				color: #333333;
				font-size: 28upx;
			}
		}

		.image_box {
			width: 100%;
			background: #fff;
			border-radius: 18upx;
			margin-bottom: 28upx;
			padding: 28upx;

			>text {
				font-size: 28upx;
				color: #333333;
				font-weight: 600;
			}

			>view {
				width: 100%;
				display: flex;
				flex-wrap: wrap;

				>image {
					flex-shrink: 0;
					width: 145upx;
					height: 145upx;
					border: 1upx solid #999;
					margin: 28upx 5upx 0;
					border-radius: 6upx;

				}
			}
		}

		.submit {
			width: 100%;
			height: 80upx;
			background: linear-gradient(180deg, #67a0ff, #ede1ff);
			border-radius: 40upx;
			color: #fff;
			font-size: 34upx;
			display: flex;
			justify-content: center;
			align-items: center;

			>image {
				width: 28upx;
				height: 28upx;
				margin-right: 12upx;
			}
		}
	}
</style>